﻿Imports MbUnit.Framework
Imports FM.NetBouncer.Rules
Imports FM.NetBouncer

<TestFixture()> _
Public Class RuleSetFixture


    <Test()> _
    Public Sub AddRules()
        Dim CustomRuleSet As New RuleSet(Of String)
        CustomRuleSet.Rules.Add(New Rules.IsNotNull())
        CustomRuleSet.Rules.Add(New Rules.IsInteger())

        Dim CustomRuleSet2 As New RuleSet(Of String)
        CustomRuleSet2.AddRulesFromRuleSet(CustomRuleSet)

        Assert.AreEqual(2, CustomRuleSet2.Rules.Count)

    End Sub

    <Test()> _
    Public Sub RulesFromRuleSet()
        Dim CustomRuleSet As New RuleSet(Of String)
        CustomRuleSet.Rules.Add(New Rules.IsNotNull())
        CustomRuleSet.Rules.Add(New Rules.IsInteger())

        Dim CustomRuleSet2 As New RuleSet(Of String)(CustomRuleSet)
        Assert.AreEqual(2, CustomRuleSet2.Rules.Count)
    End Sub


    <Test()> _
      Public Sub RuleSetNothing()
        Dim SRule As New Rules.IsDataInRange(0, 100)
        Dim TestRuleset As New RuleSet(Of String)

        'By default
        Assert.IsFalse(New BaseParameter(Of String, String)(Nothing, TestRuleset).IsValid)

        TestRuleset.AcceptNull = True
        Assert.IsTrue(New BaseParameter(Of String, String)(Nothing, TestRuleset).IsValid)
    End Sub

    <Test()> _
      Public Sub RuleSetEmpty()
        Dim SRule As New Rules.IsDataInRange(0, 100)
        Dim TestRuleset As New RuleSet(Of String)

        'By default
        Assert.IsFalse(New BaseParameter(Of String, String)(String.Empty, TestRuleset).IsValid)

        TestRuleset.AcceptEmpty = True
        Assert.IsTrue(New BaseParameter(Of String, String)(String.Empty, TestRuleset).IsValid)
    End Sub


    
End Class
